package com.vmj.test.example.natives;

import com.vmj.test.example.MyObject;

/**
 * Created by yangshoujun on 2017/9/16 下午5:39.
 */
public class ArrayCopy {

    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5,6,7,8,9,0};
        int[] n = new int[5];
        System.arraycopy(arr, 3, n, 0, n.length);
        for(int v : n) {
            System.out.println(v);
        }

        MyObject[] objs = new MyObject[10];
        for(int i = 0;i < objs.length;i++) {
            objs[i] = new MyObject();
            objs[i].instanceVar = i;
        }

        System.out.println("\n");
        MyObject[] otherObjs = new MyObject[5];
        System.arraycopy(objs, 3, otherObjs, 0, otherObjs.length);
        for(MyObject o : otherObjs) {
            System.out.println(o.instanceVar);
        }
    }
}
